package com.tgy.twodatabaseplus.kafka;

/***
 * @ClassName: Test
 * @Description: 测试Copilot
 * @Auther: 送你一块二向箔
 * @Date: 11:17 2022/4/6
 * @version : V1.0
 */
public class Test {
    //校验手机号码
    public static boolean checkPhone(String phone) {
        if (phone == null || phone.length() != 11) {
            return false;
        }
        String regex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$";
        if (phone.matches(regex)) {
            return true;
        } else {
            return false;
        }
    }
    //校验身份证号码
    public static boolean checkIdCard(String idCard) {
        if (idCard == null || idCard.length() != 18) {
            return false;
        }
        String regex = "^(\\d{6})(\\d{4})(\\d{2})(\\d{2})(\\d{3})([0-9]|X)$";
        if (idCard.matches(regex)) {
            return true;
        } else {
            return false;
        }
    }
    //校验邮箱
    public static boolean checkEmail(String email) {
        if (email == null || email.length() < 6) {
            return false;
        }
        String regex = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
        if (email.matches(regex)) {
            return true;
        } else {
            return false;
        }
    }
    //校验银行卡号
    public static boolean checkBankCard(String bankCard) {
        if (bankCard == null || bankCard.length() < 16 || bankCard.length() > 19) {
            return false;
        }
        String regex = "^\\d{16,19}$";
        if (bankCard.matches(regex)) {
            return true;
        } else {
            return false;
        }
    }
    //校验银行卡号
    public static boolean checkBankCard2(String bankCard) {
        if (bankCard == null || bankCard.length() < 16 || bankCard.length() > 19) {
            return false;
        }
        String regex = "^\\d{16,19}$";
        if (bankCard.matches(regex)) {
            return true;
        } else {
            return false;
        }
    }
    //校验银行卡号
    public static boolean checkBankCard3(String bankCard) {
        if (bankCard == null || bankCard.length() < 16 || bankCard.length() > 19) {
            return false;
        }
        String regex = "^\\d{16,19}$";
        if (bankCard.matches(regex)) {
            return true;
        } else {
            return false;
        }
    }
    //校验银行卡号
    public static boolean checkBankCard4(String bankCard) {
        if (bankCard == null || bankCard.length() < 16 || bankCard.length() > 19) {
            return false;
        }
        String regex = "^\\d{16,19}$";
        if (bankCard.matches(regex)) {
            return true;
        } else {
            return false;
        }
    }
    //校验银行卡号
    public static boolean checkBankCard5(String bankCard) {
        if (bankCard == null || bankCard.length() < 16 || bankCard.length() > 19) {
            return false;
        }
        String regex = "^\\d{16,19}$";
        if (bankCard.matches(regex)) {
            return true;
        } else {
            return false;
        }
    }


    //校验密码
    public static boolean checkPassword(String password) {
        if (password == null || password.length() < 6) {
            return false;
        }
        String regex = "^[a-zA-Z0-9]{6,16}$";
        if (password.matches(regex)) {
            return true;
        } else {
            return false;
        }
    }


    //校验密码


    public static void main(String[] args) {
        System.out.println(checkPhone("188888d8888"));
        System.out.println(checkIdCard("123456789012345678"));
        System.out.println(checkEmail("6640684@qq.com"));
        System.out.println(checkPassword("sdfsasa"));
    }


    //获取一个小时前的时间
    public static String getOneHourAgo() {
        long time = System.currentTimeMillis() - 3600000;
        return String.valueOf(time);
    }




}
